<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>订单管理</title>
		<meta name="keywords" content="Bootstrap模版,Bootstrap模版下载,Bootstrap教程,Bootstrap中文" />
		<meta name="description" content="站长素材提供Bootstrap模版,Bootstrap教程,Bootstrap中文翻译等相关Bootstrap插件下载" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<!-- basic styles -->

		<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="assets/css/font-awesome.min.css" />
        <link rel="stylesheet"  href="assets/css/kkpager_orange.css" />
        <link rel="stylesheet"  href="assets/css/MyCss.css" />

		<!--[if IE 7]>
		  <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->

		<!-- ace styles -->

		<link rel="stylesheet" href="assets/css/ace.min.css" />
		<link rel="stylesheet" href="assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="assets/css/ace-skins.min.css" />
        <link rel="stylesheet"  href="assets/css/jquery.datetimepicker.css" />

		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->

		<script src="assets/js/ace-extra.min.js"></script>

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <style>
            .panel-heading
            {
                position: relative;
            }
            .map
            {
              position: absolute;
              top:20%;
              right: 10px;
            }
        </style>
		<!--[if lt IE 9]>
		<script src="assets/js/html5shiv.js"></script>
		<script src="assets/js/respond.min.js"></script>
		<![endif]-->
	</head>

	<body >
		<#include "header.ftl"/>

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>
				<#include "left_list_menu.ftl">
				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								<a href="selectOrderList?order_type=0&page=1&order_status=0">订单管理</a>
							</li>

							<li>
								订单详情
							</li>
						</ul><!-- .breadcrumb -->

					</div>

                    <div class="page-content">
                        <div class="page-header">
                            <h1>
                                <#--订单管理-->
                                <#--<small>-->
                                    <#--<i class="ace-icon fa fa-angle-double-right"></i>-->
                                    <#--<a href="selectCustomerList?page=1">订单详情</a>-->
                                <#--</small>-->
                                <#--<small>-->
                                    <#--<i class="ace-icon fa fa-angle-double-right"></i>-->
                                    <#--订单详情-->
                                <#--</small>-->
                                <span>
                        		<button type="button" id="search_employee_list" class="btn btn-success btn-sm" data-toggle="modal" data-target="#updateOrderEmployee" style="float: right;">配单</button>
                                   <#if orderDetailView.order_status gt 2>
                                       <button id="addCustomerCoupon" type="button" data-toggle="modal"  class="btn btn-primary btn-sm" style="float:right; margin-right: 10px;">添加优惠券</button>
                                   </#if>
                    		    </span>
                            </h1>
                        </div><!-- /.page-header -->


                        <!-- 配单 -->
                        <div class="modal fade" id="updateOrderEmployee" data-backdrop="static" data-keyboard="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal">
                                            <span>&times;</span>
                                        </button>
                                        <h4 class="modal-title"> 工人列表</h4>
                                    </div>
                                    <div class="modal-body">
                                        <input type="text" name="employee_name_key" id="employee_name_key" onkeydown="onSearch(this)" placeholder="请输入关键字" />
                                        <#--<input type="text" name="manage_address_key" id="manage_address_key" placeholder="请输入负责区域" />-->
                                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                                <thead>
                                                    <tr>
                                                        <th class="center">
                                                            单选
                                                        </th>
                                                        <th>工号</th>
                                                        <th>姓名</th>
                                                        <th class="hidden-480">电话</th>
                                                        <th class="hidden-480">负责区域</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <#list employeeInfos as employeeList>
                                                    <tr>
                                                        <td class="center">
                                                            <label>
                                                                <input onclick="chooseOne(this)" name="cbox" type="checkbox" class="ace" value="${employeeList.employee_id }"/>
                                                                <span class="lbl"></span>
                                                            </label>
                                                        </td>
                                                        <td>${employeeList.employee_id }</td>
                                                        <td>${employeeList.employee_name !""}</td>
                                                        <td>${employeeList.employee_phone !""}</td>
                                                        <td>${employeeList.manage_address !""}</td>
                                                    </tr>
                                                    </#list>
                                                </tbody>
                                            </table>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-primary btn-sm"  id="updateOrderEmployeeId">保存</button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- 订单基本信息 -->
                        <div class="row">
                            <div class="col-xs-12 col-sm-12">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <h4 class="panel-title">
                                            基本信息
                                            <button type="button" class="btn btn-primary btn-xs" id="saveOrderInfo" style="float: right;margin-top:-6px;"> 保 存 </button>
                                        </h4>
                                    </div>
                                    <div class="panel-body">
                                        <form role="form" id="info" class="form-horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-1 control-label">编号 :</label>
                                                <div class="col-sm-2">
                                                    <p class=" form-control-static" id="order_id" >${orderDetailView.order_id !""}</p>
                                                </div>
                                                <label class="col-sm-2 control-label">客户姓名 :</label>
                                                <div class="col-sm-1">
                                                    <p class=" form-control-static" id="customer_name" >${orderDetailView.customer_name !""}</p>
                                                </div>
                                                <label class="col-sm-3 control-label">客户电话 :</label>
                                                <div class="col-sm-1">
                                                    <p class=" form-control-static" id="customer_name" >${orderDetailView.customer_phone !""}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-1 control-label">上门地址 :</label>
                                                <div class="col-sm-2">
                                                    <div class="shengluehao  form-control-static">${orderDetailView.address !""}${orderDetailView.house_number !""}</div>
                                                    <button type="button" class="btn btn-primary btn-xs" id="showMap" style="margin-top:-24px; float: right;"> 显示地图 </button>
                                                </div>
                                                <label class="col-sm-2 control-label">联系人 :</label>
                                                <div class="col-sm-1">
                                                    <p class=" form-control-static" id="relation_name" >${orderDetailView.relation_name !""}</p>
                                                </div>

                                                <label class="col-sm-3 control-label">联系人电话 :</label>
                                                <div class="col-sm-1">
                                                    <p class=" form-control-static" id="relation_phone" >${orderDetailView.relation_phone !""}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-1 control-label">预约日期 :</label>
                                                <div class="col-sm-2">
                                                    <input type="text" class="form-control" id="reserve_date" name="reserve_date" placeholder="" value="${orderDetailView.reserve_date?number?number_to_date !''}"/>
                                                </div>

                                                <label class="col-sm-2 control-label">预约时间段 :</label>
                                                <div class="col-sm-1">
                                                    <input type="text" class="form-control" id="reserve_time" name="reserve_time" placeholder="" value="${orderDetailView.reserve_time !''}"/>
                                                </div>
                                                <label class="col-sm-3 control-label">评分 :</label>
                                                <div class="col-sm-1">
                                                    <p class=" form-control-static" id="order_grade" >${orderDetailView.order_grade !""}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-1 control-label">订单类型 :</label>
                                                <div class="col-sm-2">
                                                    <p class=" form-control-static" id="order_type" >
                                                        <#if orderDetailView.order_type == 1>
                                                            空调
                                                        <#elseif orderDetailView.order_type == 2>
                                                            地暖
                                                        <#elseif orderDetailView.order_type == 3>
                                                            新风
                                                        <#elseif orderDetailView.order_type == 4>
                                                            生活热水
                                                        <#elseif orderDetailView.order_type == 5>
                                                            水处理
                                                        <#elseif orderDetailView.order_type == 6>
                                                            智能家居
                                                        </#if>
                                                    </p>
                                                </div>

                                                <label class="col-sm-2 control-label">订单状态 :</label>
                                                <div class="col-sm-1">
                                                    <select id="order_status">
                                                        <option value="0">请选择</option>
                                                        <#if orderDetailView.order_status == 1>
                                                            <option value="1" selected="selected">派单中</option>
                                                            <#else>
                                                            <option value="1" >派单中</option>
                                                        </#if>
                                                        <#if orderDetailView.order_status == 2>
                                                            <option value="2" selected="selected">待上门</option>
                                                        <#else>
                                                            <option value="2" >待上门</option>
                                                        </#if>
                                                        <#if orderDetailView.order_status == 3>
                                                            <option value="3" selected="selected">检修中</option>
                                                        <#else>
                                                            <option value="3" >检修中</option>
                                                        </#if>
                                                        <#if orderDetailView.order_status == 4>
                                                            <option value="4" selected="selected">待确认</option>
                                                        <#else>
                                                            <option value="4" >待确认</option>
                                                        </#if>
                                                        <#if orderDetailView.order_status == 5>
                                                            <option value="5" selected="selected">待支付</option>
                                                        <#else>
                                                            <option value="5" >待支付</option>
                                                        </#if>
                                                        <#if orderDetailView.order_status == 6>
                                                            <option value="6" selected="selected">待收款</option>
                                                        <#else>
                                                            <option value="6" >待收款</option>
                                                        </#if>
                                                        <#if orderDetailView.order_status == 7>
                                                            <option value="7" selected="selected">已完成</option>
                                                        <#else>
                                                            <option value="7" >已完成</option>
                                                        </#if>
                                                        <#if orderDetailView.order_status == 8>
                                                            <option value="8" selected="selected">已取消</option>
                                                        <#else>
                                                            <option value="8" >已取消</option>
                                                        </#if>
                                                        <#if orderDetailView.order_status == 9>
                                                            <option value="9" selected="selected">调解中</option>
                                                        <#else>
                                                            <option value="9" >调解中</option>
                                                        </#if>
                                                    </select>
                                                </div>
                                                <label class="col-sm-3 control-label">总价 :</label>
                                                <div class="col-sm-1">
                                                    <p class=" form-control-static" id="order_price" >${orderDetailView.order_price !""}</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-1 control-label">下单时间 :</label>
                                                <div class="col-sm-2">
                                                    <p class=" form-control-static" id="order_createtime" >${orderDetailView.createtime?number?number_to_date !""}</p>
                                                </div>
                                                <label class="col-sm-2 control-label">完成时间 :</label>
                                                <div class="col-sm-1">
                                                    <p class=" form-control-static" id="over_time" >${orderDetailView.over_time?number?number_to_date !""}</p>
                                                </div>
                                                <label class="col-sm-3 control-label">优惠价格 :</label>
                                                <div class="col-sm-1">
                                                    <p class=" form-control-static" id="order_price" >${orderDetailView.coupon_price?c}</p>
                                                </div>

                                            </div>
                                            <div class="form-group">

                                            <label class="col-sm-1 control-label">是否维保 :</label>
                                            <div class="col-sm-2">
                                                <select id="order_select" class="form-control-static">
                                                <#if '${orderDetailView.isInsurance !""}' == '1'>
                                                    <option value="1" selected="selected">维保订单</option>
                                                <#else>
                                                    <option value="1" >维保订单</option>
                                                </#if>
                                                <#if '${orderDetailView.isInsurance !""}' == '0'>
                                                    <option value="0" selected="selected">普通订单</option>
                                                <#else>
                                                    <option value="0" >普通订单</option>
                                                </#if>
                                                </select>
                                            </div>
                                            </div>




                                            <div class="form-group">
                                                <label class="col-sm-1 control-label">情况描述 :</label>
                                                <div class="col-sm-3">
                                                    <textarea rows="6" cols="100" disabled="disabled" style="resize: none">${orderDetailView.order_back !""}</textarea>
                                                </div>

                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-1 control-label">评价 :</label>
                                                <div class="col-sm-3">
                                                   <textarea rows="6" cols="100" disabled="disabled" style="resize: none">${orderDetailView.order_remark !""}</textarea>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-1 control-label">品牌描述 :</label>
                                                <div class="col-sm-3">
                                                    <textarea rows="6" cols="100" disabled="disabled" style="resize: none">${orderDetailView.brand_content !""}</textarea>
                                                </div>
                                            </div>
                                            <#--<div class="map">-->
                                                <#--<label class="col-sm-3 control-label">地图 :</label>-->
                                                <#--<div class="col-sm-1">-->
                                                    <#--<div id="container" style="width:500px; height:200px"></div>-->
                                                <#--</div>-->
                                            <#--</div>-->

                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- 工人信息 -->
                        <div class="row">
                            <div class="col-xs-12 col-sm-12">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <h4 class="panel-title">订单工人信息
                                        </h4>
                                    </div>
                                    <div class="panel-body" style="padding:0px">
                                        <!-- datatable 表 -->
                                        <div class="row">
                                            <div class="col-xs-12">
                                                <!-- PAGE CONTENT BEGINS -->
                                                <div class="row">
                                                    <div class="col-xs-12">
                                                        <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                                                            <thead>
                                                            <tr>
                                                                <th>工号</th>
                                                                <th>姓名</th>
                                                                <th class="hidden-480">电话</th>
                                                                <#--<th>操作</th>-->
                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            <tr>
                                                                <#if employeeInfo.employee_id != 0 >
                                                                    <td>${employeeInfo.employee_id !''}</td>
                                                                    <td>${employeeInfo.employee_name !""}</td>
                                                                    <td>${employeeInfo.employee_phone !""}</td>
                                                                    <#--<td>-->
                                                                        <#--<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">-->
                                                                            <#--<button class="btn btn-xs btn-danger" style="color: #1a1a1a" onclick="deleteThis(${orderDetailView.order_id?c},'deleteOrderEmployee')" >删除</button>-->
                                                                        <#--</div>-->
                                                                    <#--</td>-->
                                                                    <#else >
                                                                    <td>无</td>
                                                                </#if>
                                                            </tr>
                                                            </tbody>
                                                        </table>
                                                    </div><!-- /.span -->
                                                </div><!-- /.row -->
                                            </div><!-- /.col -->
                                        </div><!-- /.row -->
                                    </div>
                                </div>
                            </div>
                        </div>


                        <!-- 服务产品筛选 -->
                        <div class="modal fade" id="addOrderServiceProject" data-backdrop="static" data-keyboard="true" >
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal">
                                            <span>&times;</span>
                                        </button>
                                        <h4 class="modal-title"> 产品列表</h4>
                                    </div>
                                    <div class="modal-body">
                                       <div class="panel-body">
                                           <form id="info2" >
                                               <div class="form-group">
                                                   <label > 产品名称 :</label>
                                                       <input type="text"  name="service_name_key" id="service_name_key" onkeydown="onSearchServiceTable(this)" placeholder="请输入关键字" />
                                                   <label > 用途 :</label>
                                                       <input type="text"  name="service_kind_key" id="service_kind_key" onkeydown="onSearchServiceTable(this)" placeholder="请输入关键字" />
                                               </div>
                                               <div class="form-group">
                                                   &nbsp;&nbsp;&nbsp;&nbsp;
                                                   &nbsp;&nbsp;
                                                   <label > 品牌 :</label>
                                                       <input type="text"  name="service_brand_key" id="service_brand_key" onkeydown="onSearchServiceTable(this)" placeholder="请输入关键字" />
                                                   <label > 部件 :</label>
                                                       <input type="text"  name="service_assembly_key" id="service_assembly_key" onkeydown="onSearchServiceTable(this)" placeholder="请输入关键字" />
                                               </div>
                                               <div class="form-group">
                                                   &nbsp;&nbsp;&nbsp;&nbsp;
                                                   &nbsp;&nbsp;
                                                   <label > 规格 :</label>
                                                       <input type="text"  name="service_standard_key" id="service_standard_key" onkeydown="onSearchServiceTable(this)" placeholder="请输入关键字" />
                                               </div>
                                           </form>
                                       </div>

                                    <#--<input type="text" name="manage_address_key" id="manage_address_key" placeholder="请输入负责区域" />-->
                                        <table id="serviceProjectList" class="table table-striped table-bordered table-hover">
                                            <thead>
                                            <tr>
                                                <th class="center">
                                                    单选
                                                </th>
                                                <th>产品id</th>
                                                <th>产品名称</th>
                                                <th class="hidden-480">用途</th>
                                                <th class="hidden-480">品牌</th>
                                                <th class="hidden-480">部件</th>
                                                <th class="hidden-480">规格</th>
                                                <th class="hidden-480">总价</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <#list serviceProjects as serviceList>
                                            <tr>
                                                <td class="center">
                                                    <label>
                                                        <input onclick="chooseTwo(this)" name="123" type="checkbox" class="ace" value="${serviceList.service_id }"/>
                                                        <span class="lbl"></span>
                                                    </label>
                                                </td>
                                                <td>${serviceList.service_id !""}</td>
                                                <td>${serviceList.service_name !""}</td>
                                                <td>
                                                    <#if serviceList.service_kind == 1>
                                                        民用
                                                        <#elseif serviceList.service_kind == 2>
                                                        商用
                                                    </#if>
                                                </td>
                                                <td>${serviceList.service_brand_name !""}</td>
                                                <td>${serviceList.service_assembly_name !""}</td>
                                                <td>${serviceList.service_standard_name !""}</td>
                                                <td>${serviceList.service_all_price !""}</td>
                                            </tr>
                                            </#list>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-primary btn-sm"  id="addNewServiceProject">保存</button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- 服务项信息 -->
                        <div class="row">
                            <div class="col-xs-12 col-sm-12">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <h4 class="panel-title">订单服务项信息
                                            <#if orderDetailView.order_status == 9>
                                                <a href="OrderAddServiceProject?service_class=${orderDetailView.order_type !""}&service_brand=0&service_standard=0&service_assembly=0&service_kind=0&order_id=${orderDetailView.order_id !""}&page=1">
                                                    <button type="button"  class="btn btn-primary btn-xs" style="float:right;margin-top:-6px;">添加服务产品</button>
                                                </a>
                                            </#if>
                                        </h4>
                                    </div>
                                    <div class="panel-body" style="padding:0px">
                                        <!-- datatable 表 -->
                                        <div class="row">
                                            <div class="col-xs-12">
                                                <!-- PAGE CONTENT BEGINS -->
                                                <div class="row">
                                                    <div class="col-xs-12">
                                                        <table id="dynamic-table1" class="table table-striped table-bordered table-hover">
                                                            <thead>
                                                                <tr>
                                                                    <th>服务项编号</th>
                                                                    <th>服务项名称</th>
                                                                    <th>服务价格</th>
                                                                    <th>服务所属产品编号</th>
                                                                    <th>添加日期</th>
                                                                    <th>操作</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <#list orderServiceProjectList as serviceList>
                                                                    <tr>
                                                                        <td>${serviceList.id !""}</td>
                                                                        <td>${serviceList.service_name !""}</td>
                                                                        <td>${serviceList.service_price !""}</td>
                                                                        <td>${serviceList.service_id !""}</td>
                                                                        <td>${serviceList.createtime?number?number_to_date !""}</td>
                                                                        <td>
                                                                            <div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
                                                                                <#if orderDetailView.order_status == 9>
                                                                                    <button class="btn btn-xs btn-danger" onclick="deleteServiceProject(${orderDetailView.order_id?c},${serviceList.id?c},'deleteOrderServiceProject')">
                                                                                        删除
                                                                                    </button>
                                                                                </#if>
                                                                            </div>

                                                                            <div class="visible-xs visible-sm hidden-md hidden-lg">
                                                                                <div class="inline position-relative">
                                                                                    <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown">
                                                                                        <i class="icon-cog icon-only bigger-110"></i>
                                                                                    </button>

                                                                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close">
                                                                                        <li>
                                                                                            <a href="#" class="tooltip-success" data-rel="tooltip" title="Edit">
																					<span class="green">
																						<i class="icon-edit bigger-120"></i>
																					</span>
                                                                                            </a>
                                                                                        </li>

                                                                                        <li>
                                                                                            <a href="#" class="tooltip-error" data-rel="tooltip" title="Delete">
																					<span class="red">
																						<i class="icon-trash bigger-120"></i>
																					</span>
                                                                                            </a>
                                                                                        </li>
                                                                                    </ul>
                                                                                </div>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                </#list>
                                                            </tbody>
                                                        </table>
                                                    </div><!-- /.span -->
                                                </div><!-- /.row -->
                                            </div><!-- /.col -->
                                        </div><!-- /.row -->
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div><!-- /.page-content -->
				</div><!-- /.main-content -->

			</div><!-- /.main-container-inner -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!-- basic scripts -->


		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
        <script type="text/javascript" src="assets/js/jquery-1.10.2.min.js"></script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/typeahead-bs2.min.js"></script>

		<!-- page specific plugin scripts -->

		<script src="assets/js/jquery.dataTables.min.js"></script>
		<script src="assets/js/jquery.dataTables.bootstrap.js"></script>

		<!-- ace scripts -->

		<script src="assets/js/ace-elements.min.js"></script>
		<script src="assets/js/ace.min.js"></script>

        <script type="text/javascript" src="assets/js/kkpager.min.js"></script>

        <script src="assets/js/myJs.js"></script>
        <script src="assets/js/jquery.datetimepicker.js"></script>
		<!-- inline scripts related to this page -->

        <script src="assets/js/jquery.cookie.js"></script>
        <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=a74ce005b6e0f6647b1d23fa3b906e2e"></script>
        <script type="text/javascript">
            window.onload=function(){
                var name = $.cookie('username');
                if (name == '' || name == null || typeof(name)=="undefined"){
                    document.getElementById("user_name").innerText="unknown user";
                    alert("请先登录");
                    window.location.href='login';
                }

                document.getElementById("user_name").innerText=name;
            }


            <#if '${orderDetailView.order_status !""}' == '7' || '${orderDetailView.order_status !""}' == '8'>
$("#order_select").attr("disabled",true)
$("#order_status").attr("disabled",true)
$("#reserve_date").attr("disabled",true)
$("#reserve_time").attr("readonly","readonly")
</#if>

            <#--var map = new AMap.Map('container', {-->
            <#--resizeEnable: true,-->
            <#--zoom:11,-->
            <#--center: [${orderDetailView.poi_lat !""}, ${orderDetailView.poi_lng !""}]-->
            <#--});-->




            //显示地图
            $("#showMap").unbind("click").click(function () {
            <#if orderDetailView.address??>
                var map_status = '${orderDetailView.address?string !""}'+'${orderDetailView.house_number !""}';
                //debugger;
                window.open("http://ditu.amap.com/search?query="+map_status,"_blank");
            </#if>
            });


            //checkbox 单选
            function chooseOne(cb){
                //先取得同name的chekcBox的集合物件
                var obj = document.getElementsByName("cbox");
                for (i=0; i<obj.length; i++){
                    //判斷obj集合中的i元素是否為cb，若否則表示未被點選
                    if (obj[i]!=cb) obj[i].checked = false;
                    //若是 但原先未被勾選 則變成勾選；反之 則變為未勾選
                    //else  obj[i].checked = cb.checked;
                    //若要至少勾選一個的話，則把上面那行else拿掉，換用下面那行
                    else obj[i].checked = true;
                }
            }
            //checkbox 单选
            function chooseTwo(cb){
                //先取得同name的chekcBox的集合物件
                var obj = document.getElementsByName("123");
                for (i=0; i<obj.length; i++){
                    //判斷obj集合中的i元素是否為cb，若否則表示未被點選
                    if (obj[i]!=cb) obj[i].checked = false;
                    //若是 但原先未被勾選 則變成勾選；反之 則變為未勾選
                    //else  obj[i].checked = cb.checked;
                    //若要至少勾選一個的話，則把上面那行else拿掉，換用下面那行
                    else obj[i].checked = true;
                }
            }

            //日期
            $("#reserve_date").datetimepicker({
                format:'Y-m-d',
                timepicker:true,
                lang: 'zh',
            });

            //工人列表查询
            function onSearch(obj){//js函数开始
                setTimeout(function(){//因为是即时查询，需要用setTimeout进行延迟，让值写入到input内，再读取
                    var storeId = document.getElementById('sample-table-2');//获取table的id标识
                    var rowsLength = storeId.rows.length;//表格总共有多少行
                    var key = obj.value;//获取输入框的值

                    var searchCol = 2;//要搜索的哪一列，这里是第一列，从0开始数起
                    var searchColTwo = 4;

                    for(var i=1;i<rowsLength;i++){//按表的行数进行循环，本例第一行是标题，所以i=1，从第二行开始筛选（从0数起）
                        var searchText = storeId.rows[i].cells[searchCol].innerHTML;//取得table行，列的值

                        var searchTextTwo = storeId.rows[i].cells[searchColTwo].innerHTML;
                        if(searchText.match(key) || searchTextTwo.match(key)){//用match函数进行筛选，如果input的值，即变量 key的值为空，返回的是ture，
                            storeId.rows[i].style.display='';//显示行操作，
                        }else{
                            storeId.rows[i].style.display='none';//隐藏行操作
                        }
                    }
                },200);//200为延时时间
            }


            //产品列表查询
            function onSearchServiceTable(obj){//js函数开始
                setTimeout(function(){//因为是即时查询，需要用setTimeout进行延迟，让值写入到input内，再读取
                    var storeId = document.getElementById('serviceProjectList');//获取table的id标识
                    var rowsLength = storeId.rows.length;//表格总共有多少行

                    //产品名称
                    var service_name = $("#service_name_key").val();
                    //用途
                    var service_kind = $("#service_kind_key").val();
                    //品牌
                    var service_brand = $("#service_brand_key").val();
                    //部件
                    var service_assembly = $("#service_assembly_key").val();
                    //规格
                    var service_standard = $("#service_standard_key").val();

                    var searchCol = 2;//要搜索的哪一列，这里是第一列，从0开始数起
                    var searchColTwo = 3;
                    var searchColThree = 4;
                    var searchColFour = 5;
                    var searchColFive = 6;

                    for(var i=1;i<rowsLength;i++){//按表的行数进行循环，本例第一行是标题，所以i=1，从第二行开始筛选（从0数起）
                        var searchText = storeId.rows[i].cells[searchCol].innerHTML;//取得table行，列的值
                        var searchTextTwo = storeId.rows[i].cells[searchColTwo].innerHTML;
                        var searchTextThree = storeId.rows[i].cells[searchColThree].innerHTML;
                        var searchTextFour = storeId.rows[i].cells[searchColFour].innerHTML;
                        var searchTextFive = storeId.rows[i].cells[searchColFive].innerHTML;

                        if(service_name.trim() != null && service_name.trim() != ''){
                            if(searchText.match(service_name) ){//用match函数进行筛选，如果input的值，即变量 key的值为空，返回的是ture，
                                storeId.rows[i].style.display='';//显示行操作，
                            }else{
                                storeId.rows[i].style.display='none';//隐藏行操作
                            }
                        }
                        if(service_kind.trim() != null && service_kind.trim() != ''){
                            if(searchTextTwo.match(service_kind) ){//用match函数进行筛选，如果input的值，即变量 key的值为空，返回的是ture，
                                storeId.rows[i].style.display='';//显示行操作，
                            }else{
                                storeId.rows[i].style.display='none';//隐藏行操作
                            }
                        }
                        if(service_brand.trim() != null && service_brand.trim() != ''){
                            if(searchTextThree.match(service_brand) ){//用match函数进行筛选，如果input的值，即变量 key的值为空，返回的是ture，
                                storeId.rows[i].style.display='';//显示行操作，
                            }else{
                                storeId.rows[i].style.display='none';//隐藏行操作
                            }
                        }
                        if(service_assembly.trim() != null && service_assembly.trim() != ''){
                            if(searchTextFour.match(service_assembly) ){//用match函数进行筛选，如果input的值，即变量 key的值为空，返回的是ture，
                                storeId.rows[i].style.display='';//显示行操作，
                            }else{
                                storeId.rows[i].style.display='none';//隐藏行操作
                            }
                        }
                        if(service_standard.trim() != null && service_standard.trim() != ''){
                            if(searchTextFive.match(service_standard) ){//用match函数进行筛选，如果input的值，即变量 key的值为空，返回的是ture，
                                storeId.rows[i].style.display='';//显示行操作，
                            }else{
                                storeId.rows[i].style.display='none';//隐藏行操作
                            }
                        }
                    }
                },2000);//200为延时时间
            }

            //添加优惠券
            $("#addCustomerCoupon").click(function () {
                var customer_id = ${orderDetailView.customer_id};
                var admin_id = $.cookie('user_id');
                $.ajax({
                    type:"POST",
                    url:"addCoupon?",
                    data:{"customer_id" : customer_id,"admin_id":admin_id},
                    dataType:'json',
                    success:function(data){
                        if(data.status == 200){
                            alert("成功！");
                            window.location.reload();
                        }else{
                            alert(data.info);
                            return false;
                        }
                    },
                    error: function () {
                        alert("服务端出错！");
                        return false;
                    }
                });
            })

            //保存订单信息
            $("#saveOrderInfo").click(function () {
                //时间戳类型订单预约时间

                $("#order_select").attr("disabled",false)
                $("#order_status").attr("disabled",false)
                $("#reserve_date").attr("disabled",false)

                var reserve_date = Date.parse($("#reserve_date").val());

                var order_date_string = reserve_date / 1000 + "000";



                //预约时间段
                var reserve_time = $("#reserve_time").val();

                //订单id
                var order_id = ${orderDetailView.order_id};
                var order_status = $("#order_status").val();

                var isInsurance = $("#order_select").val();

                if(reserve_date == null || reserve_date == ''){
                    alert("预约日期不能为空");
                    return false;
                }

                if(reserve_time.trim() == null || reserve_time.trim() == ''){
                    alert("预约时间段不能为空");
                    return false;
                }

                if(order_status == 0){
                    alert("订单状态不能为空");
                    return false;
                }
              //  alert(isInsurance)
                $.ajax({
                    type:"POST",
                    url:"updateOrderStatus?",
                    data:{"order_id" : order_id,"order_status" : order_status,"reserve_date":order_date_string,"reserve_time":reserve_time,"isInsurance":isInsurance},
                    dataType:'json',
                    success:function(data){
                        if(data.status == 200){
                            alert("成功！");
                            window.location.reload();
                        }else{
                            alert(data.info);
                            return false;
                        }
                    },
                    error: function () {
                        alert("服务端出错！");
                        return false;
                    }
                });

            })

			jQuery(function($) {
//                var oTable1 = $('#sample-table-2').dataTable( {
//                    "aoColumns": [
//                        { "bSortable": false },
//                        null, null,null, null,
//                        { "bSortable": false }
//                    ] } );
				
				
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});

				$("#updateOrderEmployeeId").click( function () {
                    var order_id = ${orderDetailView.order_id};
                    var employee_id=document.getElementsByName("cbox");
                    var objarray = employee_id.length;
                    var chestr="";
                    for (i=0;i<objarray;i++) {//欢迎来到站长特效网，我们的网址是www.zzjs.net，很好记，zz站长，js就是js特效，本站收集大量高质量js代码，还有许多广告代码下载。
                        if (employee_id[i].checked == true) {
                            chestr = employee_id[i].value;
                        }
                    }
                    $.ajax({
                        type:"POST",
                        url:"updateOrderEmployee?",
                        data:{"employee_id" : chestr,"order_id" : order_id},
                        dataType:'json',
                        success:function(data){
                            if(data.status == 200){
                                alert("成功！");
                                window.location.reload();
                            }else{
                                alert(data.info);
                                return false;
                            }
                        },
                        error: function () {
                            alert("服务端出错！");
                            return false;
                        }
                    });

                })

                //添加服务项
                $("#addNewServiceProject").click( function () {
                    var order_id = ${orderDetailView.order_id};
                    var employee_id=document.getElementsByName("123");
                    var objarray = employee_id.length;
                    var chestr="";
                    for (i=0;i<objarray;i++) {//欢迎来到站长特效网，我们的网址是www.zzjs.net，很好记，zz站长，js就是js特效，本站收集大量高质量js代码，还有许多广告代码下载。
                        if (employee_id[i].checked == true) {
                            chestr = employee_id[i].value;
                        }
                    }
                    $.ajax({
                        type:"POST",
                        url:"orderAddServiceProject?",
                        data:{"service_id" : chestr,"order_id" : order_id},
                        dataType:'json',
                        success:function(data){
                            if(data.status == 200){
                                alert("成功！");
                                window.location.reload();
                            }else{
                                alert(data.info);
                                return false;
                            }
                        },
                        error: function () {
                            alert("服务端出错！");
                            return false;
                        }
                    });

                })


				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
			})
		</script>
<#--<script type="text/javascript">-->
<#--var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");-->
<#--document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fe9e1d61340ff3d9495a8cca04ebdb49d' type='text/javascript'%3E%3C/script%3E"));-->
<#--</script>-->
<#--<a href="http://www.iteblog.com">过往记忆</a>-->
</body>
</html>
